#pragma once
#include "TypeInfo.h"

#include <type_traits>

#define RZ_AS_METHOD(className)														\
	template <typename T> T As() const		{ return static_cast<T>(this);  }		\
	template <typename T> T As()			{ return static_cast<T>(this);  }		\
	template <typename T> T CastTo() const	{ return rz_dynamic_cast<T>(this); }	\
	template <typename T> T CastTo()		{ return rz_dynamic_cast<T>(this); }	\
	const className*		AsConst() const { return static_cast<const className*>(this); }

RZ_CLASS_FWD_DECL1(Rz, IObject);

template <typename T>
T rz_dynamic_cast(const ::Rz::IObject* ptr)
{
	return static_cast<T>(ptr->To(std::remove_pointer<T>::type::GetTypeInfoStatic()->GetFullClassNameHash()));
}

template <typename T>
T rz_dynamic_cast(::Rz::IObject* ptr)
{
	return static_cast<T>(ptr->To(std::remove_pointer<T>::type::GetTypeInfoStatic()->GetFullClassNameHash()));
}

